////////////////////////////////////////////////////////
// CodePlex - metacpp
//--------------------
// This file is part of "metacpp" project on CodePlex. The
// goal if the project is to demonstrate basic techniques
// used in C++ metaprogrammins.
// For more info and comments please visit:
// http://www.codeplex.com/metacpp/
////////////////////////////////////////////////////////

#include <memory.h>
#include <iostream>


////////////////////////////////////////
// STATIC (compile-time) ASSERTS
//
// Can be used to verify that templates are
// instantiationed with appropriate types

template<bool> struct CompileTimeError;
template<> struct CompileTimeError<true> {};

#define STATIC_ASSERT(exp) (CompileTimeError< (exp) >())


template<typename T1, typename T2>
void dumb_copy(const T1 from, T2 to) {
	STATIC_ASSERT(sizeof(T2) >= sizeof(T1));
	memcpy(&to, &from, sizeof(T1));
}


void show_static_assert(void) {
	char c = 'a';
	int i = 10;
	dumb_copy(c, i);
	//dumb_copy(i, c);
}